package modules.citysection.bottom
{
import framework.view.components.container.RepeaterRenderProxy;

import values.friend.FriendValue;

import view.component.asset.IconProxy;

/**
 * FriendItemRenderProxy
 * @author jliang
 *
 */
public class FriendItemRenderProxy extends RepeaterRenderProxy
{
    //==========================================================================
    //  Constructor
    //==========================================================================
    public function FriendItemRenderProxy()
    {
        super();
    }
    //==========================================================================
    //  Properties
    //==========================================================================
    protected function get holder():IconProxy
    {
        return proxys["holder"];
    }
    //==========================================================================
    //  Overridden methods: ComponentProxy
    //==========================================================================
    override protected function get proxyMapping():Array
    {
        return [ 
            { skin:"holder", classRef: IconProxy, id:"holder" }
        ].concat(super.proxyMapping);
    }
    
    protected var vo:FriendValue;
    
    override public function set data(value:*):void
    {
        vo = value;
        
        if (data == null)
        {
            hide();
            return;
        }
        
        skin.emptyHolder.mouseChildren = skin.emptyHolder.visible = false;
        skin.holder.visible = true;
        
        //名字
        skin.nameLabel.text = vo.name;
        
        //等级
        skin.levelLabel.text = String(vo.level);
        
        //VIP
        skin.vipIcon.visible = vo.isVIP;
        
        //职业
        if (vo.avatarType)
        {
            skin.typeIcon.visible = true;
            skin.typeIcon.gotoAndStop(vo.avatarType);
        }
        else
        {
            skin.typeIcon.visible = false;
        }
        
        //头像
        //Todo....
    }
    
    override public function get data():*
    {
        return vo;
    }
    
    override public function hide():void
    {
        holder.stopAndRemove();
        skin.emptyHolder.mouseChildren = skin.emptyHolder.visible = true;
        skin.holder.visible = false;
    }
}
}





